/**
 *
 */
package urban;

import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;

/**
 * @author emily
 *
 */
public class Sentence extends StringObject implements Comparable<Sentence> {

	String sentence;
	int numUrbanWord;
	int totalWordCount;
	float percent;
	String word;

	public Sentence(String word, String sentence) throws XMLStreamException {
		sentence = sentence.trim();
		this.sentence = sentence;
		this.totalWordCount = sentence.split(" ").length;
		this.word = word;
	}

	@Override
	void fillEventInfo(XMLStreamReader reader) throws XMLStreamException {
		// TODO Auto-generated method stub

	}

	public String getSentence() {
		return this.sentence;
	}

	public String toString() {
		return "Word: "+word+" NumUrbanWord: "+numUrbanWord+" Count: "+totalWordCount+" Percent: "+this.percent+" "+this.sentence;
	}

	@Override
	public void run() {
		// TODO Auto-generated method stub

	}

	public int getNumUrbanWord() {
		return numUrbanWord;
	}

	public void setNumUrbanWord(int numUrbanWord) {
		this.numUrbanWord = numUrbanWord;
		this.setPercent();
	}

	public float getPercent() {
		return percent;
	}

	public void setPercent() {
		this.percent = ((float)numUrbanWord*100)/totalWordCount;
		int i = 0;
	}

	public int compare(Sentence arg0, Sentence arg1) {
		if(arg0.numUrbanWord > arg1.numUrbanWord) return 1;
		if(arg0.numUrbanWord < arg1.numUrbanWord) return -1;
		return 0;
	}

	@Override
	public int compareTo(Sentence arg0) {
		if(this.getPercent() > arg0.getPercent()) return -1;
		else return 1;
	}
}
